package com.abl.javabasis._06_面向对象;

class People {
    //人员年龄，私有属性，不可以被外部访问
    private int age = 0;
    //人员姓名，私有属性，不可以被外部访问
    private String name = null;

    //提供交互方法，读取属性
    public int getAge() {
        return age;
    }

    //提供交互方法，设置属性值
    public void setAge(int age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}

public class 封装 {
    public static void main(String[] args) {

        People people = new People();

        System.out.println(people.getName() + " : " + people.getAge());//null : 0

        people.setName("小明");
        people.setAge(20);
        System.out.println(people.getName() + " : " + people.getAge());//小明 : 20


    }
}
